package com.zhaojiadi.abstractfactory.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @Date: 2021/8/26
 * @Description:
 */
public class ClassLoaderUtils {
    public static Class<?>[] getClassByArgs(Object[] args){
        Class<?>[] parameterTypes = new Class[args.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            Object arg = args[i];
            if(arg instanceof ArrayList){
                parameterTypes[i]= List.class;
                continue;
            }else if(arg instanceof HashMap){
                parameterTypes[i]= Map.class;
                continue;
            }else if(arg instanceof Long){
                parameterTypes[i]=Long.class;
                continue;
            }else if(arg instanceof  Double){
                parameterTypes[i]=double.class;
                continue;
            }else if(arg instanceof TimeUnit){
                parameterTypes[i]=TimeUnit.class;
                continue;
            }
            parameterTypes[i]=arg.getClass();
        }
        return parameterTypes;
    }
}
